package com.gps.pe.exception;

import java.util.ArrayList;
import java.util.List;

/**
 * Result of validation
 * 
 * @author GPS
 *
 */
public class ValidationResult {

	/** Result type. */
	public enum Type {
		OK, ERROR, DEFAULT
	};

	/** Result type. */
	private Type type = Type.OK;

	/** List of validation errors. */
	private List<ValidationError> errors = new ArrayList<ValidationError>();

	/**
	 * Constructor.
	 * 
	 * @param type
	 *            result type
	 * @param errors
	 *            list of errors
	 */
	public ValidationResult(Type type, List<ValidationError> errors) {
		super();
		this.type = type;
		this.errors = errors;
		if (errors == null) {
			this.errors = new ArrayList<ValidationError>();
		}
	}

	/**
	 * @return the errors
	 */
	public List<ValidationError> getErrors() {
		return errors;
	}

	/**
	 * Adds validation error.
	 * 
	 * @param validationError
	 *            validation error
	 */
	public void addError(ValidationError validationError) {
		errors.add(validationError);
	}

	/**
	 * Return result type.
	 * 
	 * @return
	 */
	public Type getType() {
		return type;
	}
}
